/* Copyright (C) 2010 Fredrique Samuels, fredriquesamuels@gmail.com 

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef TRI_MATRIX_H_
#define TRI_MATRIX_H_

#include "vector.h"
#include <math.h>
#include <iostream>


namespace tri
{


class matrix
{
    friend std::ostream &operator<<( std::ostream&, const matrix&);
    
public:
    matrix();
    virtual ~matrix();
    
    
    
    float elements[16];
    
    /**load a 4x4 matrix identity matrix 
        
    @param m: target matrix
    */
    static void load_identity(tri::matrix* m);
    
    /**
     * Translate a given matrix
     * 
     *@param m target matrix
     *@param x: x value
     *@param y: y value
     *@param z: z value
     */
    static void translate(matrix* m,float x,float y,float z);
    
    /**
     * load a rotation matrix
     * 
     * @param rot : Rotation in degrees
     * @param m : Target matrix 
     */
    static void get_rotation_matrixX(float rot,matrix*m);
    
    /**
     * load a rotation matrix
     * 
     * @param rot : Rotation in degrees
     * @param m : Target matrix 
     */
    static void get_rotation_matrixY(float rot,matrix*m);
    
    /**
     * load a rotation matrix
     * 
     * @param rot : Rotation in degrees
     * @param m : Target matrix 
     */
    static void get_rotation_matrixZ(float rot,matrix*m);
    
    /**
     * load a rotation matrix
     * 
     * @param rot : Rotation in degrees
     * @param m : Target matrix 
     */
    static void get_rotation_matrixXYZ(float x,float y,float z,matrix*m);
    /**Calculate the product of 2 matrix 
        
    @param m1: Matrix 1
    @param m2: Matrix 2 
    @param dst: Product of m1 and m2
    */
    static void mult_mat(const matrix*m1,const matrix*m2,matrix*dst);
    
    /**Calculate the product of a matrix and a vector 
        
    @param m: Matrix
    @param v: Vector
    @param dst: Product of m and v
    */
    static void mult_vmat(const matrix* m,const vector* v,vector* dst);
};

}

#endif /*MATRIX_H_*/
